Crate backhand

source ·
Expand description

Library and binaries for the reading, creating, and modification of SquashFS file systems.

§Library

Add the following to your Cargo.toml file:

[dependencies]
backhand = "0.15.0"

§Reading

For reading an image and extracting its details and contents, use FilesystemReader::from_reader.

§Writing

For creating a modified or new image, use FilesystemWriter::from_fs_reader. FilesystemWriter can also be created from scratch, without a previous image to base itself on.

§Example

 // read
 let file = BufReader::new(File::open("file.squashfs").unwrap());
 let read_filesystem = FilesystemReader::from_reader(file).unwrap();

 // convert to writer
 let mut write_filesystem = FilesystemWriter::from_fs_reader(&read_filesystem).unwrap();

 // add file with data from slice
 let d = NodeHeader::default();
 let bytes = Cursor::new(b"Fear is the mind-killer.");
 write_filesystem.push_file(bytes, "a/d/e/new_file", d);

 // add file with data from file
 let new_file = File::open("dune").unwrap();
 write_filesystem.push_file(new_file, "/root/dune", d);

 // replace a existing file
 let bytes = Cursor::new(b"The sleeper must awaken.\n");
 write_filesystem
     .replace_file("/a/b/c/d/e/first_file", bytes)
     .unwrap();

 // write into a new file
 let mut output = File::create("modified.squashfs").unwrap();
 write_filesystem.write(&mut output).unwrap();

§Features

  • xz (enabled by default) — Enables xz compression inside library and binaries
  • xz-static — Enables xz compression and forces static build inside library and binaries
  • gzip (enabled by default) — Enables gzip compression inside library and binaries
  • gzip-zune-inflate — Enables faster gzip (de-compression only) inside library and binaries Cannot be used with the gzip feature
  • lzo — This library is licensed GPL and thus disabled by default
  • zstd (enabled by default) — Enables zstd compression inside library and binaries

Modules§

  • Compression Choice and Options
  • Support the wonderful world of vendor formats

Structs§

Enums§

Constants§

Traits§